package com.ktgj.hotel.service.impl;

import java.util.List;

import com.ktgj.hotel.domain.HotelOrder;
import com.ktgj.hotel.mapper.HotelOrderMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ktgj.hotel.mapper.HotelOrderInvoiceMapper;
import com.ktgj.hotel.domain.HotelOrderInvoice;
import com.ktgj.hotel.service.IHotelOrderInvoiceService;

/**
 * 酒店订单发票Service业务层处理
 * 
 * @author ruoyi
 * @date 2021-12-08
 */
@Service
public class HotelOrderInvoiceServiceImpl implements IHotelOrderInvoiceService 
{
    @Autowired
    private HotelOrderInvoiceMapper hotelOrderInvoiceMapper;
    @Autowired
    private HotelOrderMapper hotelOrderMapper;

    /**
     * 查询酒店订单发票
     * 
     * @param invoiceid 酒店订单发票ID
     * @return 酒店订单发票
     */
    @Override
    public HotelOrderInvoice selectHotelOrderInvoiceById(Long invoiceid)
    {
        return hotelOrderInvoiceMapper.selectHotelOrderInvoiceById(invoiceid);
    }

    /**
     * 查询酒店订单发票列表
     * 
     * @param hotelOrderInvoice 酒店订单发票
     * @return 酒店订单发票
     */
    @Override
    public List<HotelOrderInvoice> selectHotelOrderInvoiceList(HotelOrderInvoice hotelOrderInvoice)
    {
        return hotelOrderInvoiceMapper.selectHotelOrderInvoiceList(hotelOrderInvoice);
    }

    /**
     * 新增酒店订单发票
     * 
     * @param hotelOrderInvoice 酒店订单发票
     * @return 结果
     */
    @Override
    public int insertHotelOrderInvoice(HotelOrderInvoice hotelOrderInvoice)
    {
        return hotelOrderInvoiceMapper.insertHotelOrderInvoice(hotelOrderInvoice);
    }

    /**
     * 修改酒店订单发票
     * 
     * @param hotelOrderInvoice 酒店订单发票
     * @return 结果
     */
    @Override
    public int updateHotelOrderInvoice(HotelOrderInvoice hotelOrderInvoice)
    {
        return hotelOrderInvoiceMapper.updateHotelOrderInvoice(hotelOrderInvoice);
    }

    /**
     * 批量删除酒店订单发票
     * 
     * @param invoiceids 需要删除的酒店订单发票ID
     * @return 结果
     */
    @Override
    public int deleteHotelOrderInvoiceByIds(Long[] invoiceids)
    {
        return hotelOrderInvoiceMapper.deleteHotelOrderInvoiceByIds(invoiceids);
    }

    /**
     * 删除酒店订单发票信息
     * 
     * @param invoiceid 酒店订单发票ID
     * @return 结果
     */
    @Override
    public int deleteHotelOrderInvoiceById(Long invoiceid)
    {
        return hotelOrderInvoiceMapper.deleteHotelOrderInvoiceById(invoiceid);
    }

    /**
     * 新增酒店订单发票
     */
    @Override
    public int addHotelOrderInvoice(HotelOrderInvoice hotelOrderInvoice) {
        HotelOrder hotelOrder = hotelOrderMapper.selectHotelOrderByOrderNum(hotelOrderInvoice.getOrderNum());
        hotelOrderInvoice.setOrderid(hotelOrder.getOrderid());
        hotelOrderInvoice.setInvoicetype(1l);
        hotelOrderInvoice.setInvoiceoption(1l);
        int i = hotelOrderInvoiceMapper.insertHotelOrderInvoice(hotelOrderInvoice);
        return i;
    }
}
